import { AuthGuard, ReplaceableComponents, ReplaceableRouteContainerComponent } from '@abp/ng.core';
import { eIdentityComponents } from '@abp/ng.identity';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { UserRoleComponent } from './user-role/user-role.component';
import { UserListComponent } from './user-list/user-list.component';
import { UserDetailComponent } from './user-detail/user-detail.component';

const routes: Routes = [
  {
    path: 'users',
    component: ReplaceableRouteContainerComponent,
    canActivate: [AuthGuard],
    data: {
      replaceableComponent: {
        key: eIdentityComponents.Users,
        defaultComponent: UserListComponent,
      } as ReplaceableComponents.RouteData<UserListComponent>,
    },
  },
  {
    path: 'user-detail',
    component: ReplaceableRouteContainerComponent,
    canActivate: [AuthGuard],
    data: {
      replaceableComponent: {
        key: 'Identity.UserDetailComponent',
        defaultComponent: UserDetailComponent,
      } as ReplaceableComponents.RouteData<UserDetailComponent>,
    },
  },
  {
    path: 'roles',
    component: ReplaceableRouteContainerComponent,
    canActivate: [AuthGuard],
    data: {
      replaceableComponent: {
        key: eIdentityComponents.Roles,
        defaultComponent: UserRoleComponent,
      } as ReplaceableComponents.RouteData<UserRoleComponent>,
    },
  },
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class IdentityRoutingModule {}
